<?php
require_once($_SERVER['DOCUMENT_ROOT'] . '/../start.php');//Подключаем файл инициализации

$destination_path = getcwd().DIRECTORY_SEPARATOR . '../../content/upload_files/';
$arrFile = $_FILES['myfile'];
echo '<pre>';
print_r($arrFile);
echo '</pre>';
$arrFile['unique_name'] = date('Y_m_d_H_i_s');
$target_path = $destination_path . basename($arrFile['unique_name']);
$folderId = intval($_POST['uploadFolderId']);

if(move_uploaded_file($arrFile['tmp_name'], $target_path)) {
$result = 'Файл успешно загружен';
Main::saveFile($arrFile, $folderId);
  }
else $result = 'Ошибка загрузки';

sleep(1);
?>

<script language="javascript" type="text/javascript">window.top.window.upload.stopUpload("<?php echo $result; ?>");</script>
